#!/bin/bash

status "Downloading tarfile"

version=https://github.com/TeamRizu/OutFox/releases/download/OF4.19.0/OutFox-0.4.19-LTS-Linux-RPi32bit-arm32v7-modern-date-20230415.tar.gz

mkdir -p ~/ProjectOutFox && cd ~/ProjectOutFox || error "Could not create or move to directory"
rm -rf ./*
wget -O ProjectOutFox.tar.gz "$version" || error "Could not download tarfile"
tar -xvf ProjectOutFox.tar.gz || error "Could not extract tarfile"
rm -f ProjectOutFox.tar.gz
folder_name="$(ls -t | grep 'OutFox-')"

mkdir -p ~/.local/share/applications
# add .desktop file
echo "[Desktop Entry]
Encoding=UTF-8
Name=Project OutFox
GenericName=Rhythm and dance game
Exec=$HOME/ProjectOutFox/$folder_name/OutFox
Terminal=false
Icon=$(dirname "$0")/icon-64.png
Type=Application
Categories=Application;Game;ArcadeGame
Comment=A cross-platform rhythm video game." | tee ~/.local/share/applications/projectoutfox.desktop || error "Could not created .desktop file"

status_green "Install finished"
